<%-- 
    Document   : listPlans
    Created on : Mar 25, 2012, 6:36:41 PM
    Author     : Waseem
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="./css/main.css" type="text/css"/>
        <style>
            body {
                background-color : white;
            }
        </style>
        
    <script src="./js/prototype.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    <script src="./js/datepicker.js"></script>
    <script src="./js/pushPlans.js"></script>
    </head>
    <body>
        
        <h2>My Created Plans</h2>
        <c:forEach items="${userPlans.listPlans}" var="plan" varStatus="loopCount">
            <div class="plansview_list">
                ${plan.planName}
                <a href="javascript:showDatePicker(${loopCount.count})">
                    Join
                </a>
                &nbsp;
            </div>
            <div id="datePicker${loopCount.count}" style="display:none">
                <form action="Plans" method="post" >
                    Year: <input type="text" name="year"></input><br/>
                    Month: <input type="text" name="month"></input><br/>
                    Day: <input type="text" name="day"></input><br/>
                    <input type="hidden" name="action" value="join"></input>
                    <input type="hidden" name="planId" value="${plan.planID}"></input>
                    <input type="submit" value="Join!"></input><br/>
                    <input type="hidden" name="from" value="list"></input>
                </form>
            </div>
            <c:choose>
                <c:when test="${user.isDoctor}">
                    <div>
                        <form name="pushPlan${plan.planID}" action="Plans" method="post">
                            Push this plan?
                            <select name="patientSelect">
                                <c:forEach items="${userFriends.friendList}" var="friend" varStatus="loopCount">
                                    <option value="${friend.friendId}">${friend.friendName}</option>
                                </c:forEach>
                            </select>
                            <input type="hidden" name="planId" value="${plan.planID}"></input> 
                            <input type="hidden" name="doctorId" value="${user.userID}"></input>
                            <a href="javascript:submitPlanPush(${plan.planID})">Push!</a>
                        </form>
                    </div>
                </c:when>
            </c:choose>
        </c:forEach>
        
        <h2>Joined Plans</h2>
        <c:forEach items="${searchedPlans.listPlans}" var="plan" varStatus="loopCount">
            <div class="plansview_list">
                ${plan.planName}
                
            </div>
        </c:forEach>
    </body>
</html>
